define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'dealer.delivery_order/index',
        add_url: 'dealer.delivery_order/add',
        edit_url: 'dealer.delivery_order/edit',
        delete_url: 'dealer.delivery_order/delete',
        export_url: 'dealer.delivery_order/export',
        modify_url: 'dealer.delivery_order/modify',
        refund_url: 'dealer.delivery_order/refund',
    };

    return {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh','export'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'order_sn', title: '订单编号' ,width:160},
                    {field: 'total_amount', title: '总金额', minWidth: 120 ,search:'false'
                    ,templet: function(d){
                        if (d.total_amount == null) {
                            return'￥0.00';
                        } else {
                            return '￥'+d.total_amount;
                        }
                    }},
                    {field: 'goods_images', title: '商品图', minWidth: 80, templet: ea.table.lazyimg ,search:'false'},
                    {field: 'goods_num', type: 'hidden', title: '商品数量', minWidth: 80,selectList: {"0":"全部","1":"10袋以下","2":"10袋及以上"}},
                    {field: 'goods_num', title: '实发商品', minWidth: 100 ,search:'false',templet: function(d){
                        return d.goods_name+' *'+(d.goods_num+d.gift_num);
                    }},
                    {field: 'goods_num', title: '商品信息', minWidth: 200 ,search:'false',templet: function(d){
                        if (d.gift_num > 0) {
                            return' 商品:'+d.goods_num+' 赠品:'+d.gift_num;
                        } else {
                            return' 商品:'+d.goods_num;
                        }
                    }},
                    {field: 'order_name', title: '收货人' ,hide: true},
                    {field: 'order_phone', title: '手机号' ,hide: true},
                    {field: 'order_address',title: '订单信息' ,minWidth:300 ,search:'false' ,templet: function(d){
                        return d.order_name+' '+d.order_phone+' '+d.province+''+d.city+''+d.area+''+d.order_address;
                    }},
                    {field: 'refund_status',title: '退款状态', search: 'select', selectList: {0: '未退款', 1: '已退款'},templet: function(d){
                        if (d.refund_status == 1) {
                            return'已退款';
                        } else {
                            return '未退款';
                        }
                    }},
                    {field: 'remark', Width: 100, title: '备注', search: 'false'},
                    {field: 'goods_num', hide: true, title: '商品数量', minWidth: 80,selectList: {"1":"10袋以下","2":"10袋及以上"}},
                    {field: 'create_time', minWidth: 200, title: '创建时间', search: 'range'},
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
});